package com.shangxia.product.controller;

import com.shangxia.feign.model.SX_Product;
import com.shangxia.product.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zhouya38158
 * @date 2021/11/2 14:46
 */
@Slf4j
@RestController
@RequestMapping("/product")
@Api("product")
public class ProductController {

    @Autowired
    private ProductService productService;

    @GetMapping("/{id}")
    @ApiOperation(value = "product", notes = "product")
    public SX_Product queryById(@ApiParam("id") @PathVariable("id") Long id) {
        return productService.queryById(id);
    }

    @PostMapping("/ids")
    @ApiOperation(value = "product", notes = "查询产品")
    public List<SX_Product> listByIds(@ApiParam("id") @RequestParam("ids") String ids) {
        return productService.listByIds(ids);
    }

    /**
     * 根据 订单id 查询产品
     *
     * @param ids 订单id
     * @return 产品
     */
    @PostMapping("/list")
    @ApiOperation(value = "product", notes = "查询产品")
    public List<SX_Product> listByIds(@RequestBody() List<Long> ids) {
        return productService.listByListIds(ids);
    }
}
